package sample.reflects;

class Person {
	private String name;
	private int age;

	public String getName() {
		return name;
	}

	public void setName(String name) {
		this.name = name;
	}

	public int getAge() {
		return age;
	}

	public void setAge(int age) {
		this.age = age;
	}

	public String toString() {
		return "[" + this.name + " " + this.age + "]";
	}

	//Error if exist  when running 
/**	public Person(String name,int age){
		this.age=age;
		this.name=name;
	}**/
	
	public Person(){
		this.name="s";
		this.age=10;
	}
}

public class HelloPerson {

	public static void main(String[] args) {
		Class<?> demo = null;

		try {
			demo = Class.forName("sample.reflects.Person");
		} catch (ClassNotFoundException e) {
			e.printStackTrace();
		}
		Person per = null;

		try {
			per = (Person) demo.newInstance();
		} catch (InstantiationException e) {
			e.printStackTrace();
		} catch (IllegalAccessException e) {
			e.printStackTrace();
		}

		per.setName("Anqing");
		per.setAge(1000);
		System.out.println(per);
	}

}
